package com.yy.ptrdemo.library;

import android.view.View;
import android.view.animation.Interpolator;
import com.yy.ptrdemo.library.loadinglayout.ILoadingLayout;
import com.yy.ptrdemo.library.utils.CustomEnums;

/**
 * Created by Ayanami_Rei on 2014/9/2.
 *
 * Pull to refresh interface
 */
public interface IPullToRefresh<T extends View> {


    /**
     * Demos the Pull_To_Refresh functionality to the user so that they are
     * aware it is there. This could be useful when the user first time to
     * opens your app, etc. The animation will only happen if the Refresh View
     * (ListView, ScrollView, etc) is in a state where a Pull_To_Refresh could
     * occur by a user's touch gesture (i.e. scrolled to the top/bottom)
     *
     * return true if the Demo has been started, false is not
     */
    public boolean demo();

    /**
     * Get the mode that this view currently in. This is really useful
     * when using <code>CustomEnums.Mode.BOTH</code>
     */
    public CustomEnums.Mode getCurrentMode();

    /**
     * Returns whether the touch events are filtered or not. If true is
     * returned, then the view only use touch events where the difference
     * in the Y-axis greater than the difference in the X-axis. This means
     * that the view will not interfere when it is used in a horizontal
     * scrolling view (such as ViewPager)
     */
    public boolean isFilterTouchEvents();

    /**
     * Returns a proxy object which allows you to call all methods on all
     * of LoadingLayouts (the Views which show when pulling/refreshing)
     *
     * You should not keep the result of this method any longer than you
     * need it
     */
    public ILoadingLayout getLoadingLayoutProxy();

    /**
     * Returns a proxy object which allows you to call all methods on all
     * of LoadingLayouts (the View which show when Pulling/Refreshing).
     * The actual LoadingLayout which will be affected, are chosen by parameters
     * you give
     *
     * You should not keep result of this method any longer than you need it
     *
     * @param includeStart Whether to include the Start/Header Views
     * @param includeEnd Whether to include the End/Footer Views
     */
    public ILoadingLayout getLoadingLayoutProxy(boolean includeStart, boolean includeEnd);

    /**
     * Get the mode that this View has been set to. If this returns
     * <Code>CustomEnums.Mode.BOTH</Code>, you can use
     * <Code>getCurrentMode()</Code> to check which mode the view is
     * currently in
     */
    public CustomEnums.Mode getMode();

    /**
     * Get the wrapped Refreshable View. Anything returned here has already
     * add to the content view
     */
    public T getRefreshableView();

    /**
     * Get whether the "Refreshing" view should be automatically shown when
     * refreshing. Returns true by default
     */
    public ILoadingLayout getShowViewWhileRefreshing();

    /**
     * Returns the state the view is currently in
     */
    public CustomEnums.State getState();

    /**
     * Whether the Pull_To_Refresh is enable
     */
    public boolean isPullToRefreshEnable();

    /**
     * Returns true if both pull_to_refresh over scroll and android
     * inbuilt over scroll are enable
     */
    public boolean isPullToRefreshOverScrollEnable();

    /**
     * Returns whether the widget is currently in the refreshing.
     */
    public boolean isRefreshing();

    /**
     * Returns whether the widget has enable scrolling on the
     * Refreshable View while refreshing
     */
    public boolean isScrollingWhileRefreshingEnabled();

    /**
     * Mark the current refresh as complete, will reset UI and
     * hide the refreshing view
     */
    public void onRefreshComplete();

    /**
     * Set the touch events to be filtered or not. If set to true,
     * then the View will only use touch events where the difference
     * in the Y-axis is greater than the difference in the X-axis.
     * This means that the View will not interfere when it is used in
     * a horizontal scrolling view (such as ViewPager), but will restrict
     * which types of finger scrolls will trigger the view.
     */
    public void setFilterTouchEvent(boolean filterEvent);

    /**
     * Set the mode of pull_to_refresh that this view will use
     */
    public void setMode(CustomEnums.Mode mode);

    /**
     * Set OnPullEventListener to widget
     *
     * @param listener to be used when the widget has a
     *                 pull event to propagate
     */
    public void setOnPullEventListener(PullToRefreshBase.OnPullEventListener<T> listener);

    /**
     * Set OnRefreshListener to widget
     *
     * @param listener to be used when the widget refresh
     */
    public void setOnRefreshListener(PullToRefreshBase.OnRefreshListener<T> listener);

    /**
     * Set OnRefreshListener to widget
     *
     * @param listener to be used when the widget refresh
     */
    public void setOnRefreshListener(PullToRefreshBase.OnRefreshListenerBoth<T> listener);

    /**
     * Sets whether over scroll support is enable. This is different to android's
     * standard over scroll support (the edge-glow). This setting only takes effect
     * when running on device with android 2.3 or greater
     */
    public void setPullToRefreshOverScrollEnabled(boolean enabled);

    /**
     * Sets the widget to be in the refreshing state. The UI will be updated to
     * show 'Refreshing' View, and be scrolled to show such
     */
    public void setRefreshing();

    /**
     * Sets the widget to be in the refreshing state. The UI will be updated to
     * show 'Refreshing' View
     *
     * @param doScroll Whether be scrolled to show such
     */
    public void setRefreshing(boolean doScroll);

    /**
     * Sets the animation interpolator that is used for animated scrolling
     * Defaults to a decelerate interpolator
     */
    public void setScrollAnimationInterpolator(Interpolator interpolator);

    /**
     * By default the widget disables scrolling on the refresh view while
     * refreshing. This method can change this behaviour
     */
    public void setScrollingWhileRefreshingEnabled(boolean enabled);

    /**
     * Sets whether the 'Refreshing' view should be automatically shown when refreshing
     */
    public void setShowViewWhileRefreshing(boolean showView);
}
